home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10246 < prev    next >
Encoding:
Text File  |  1996-08-05  |  933 b   |  32 lines

  1. Path: muccmail.missouri.edu!menghua_wang
  2. From: menghua_wang@muccmail.missouri.edu (menghua wang)
  3. Newsgroups: comp.lang.c++
  4. Subject: question assignment operator in c++
  5. Date: Wed, 6 Mar 1996 15:27:29 UNDEFINED
  6. Organization: University of Missouri - Columbia
  7. Message-ID: <menghua_wang.1.002DB7BE@muccmail.missouri.edu>
  8. NNTP-Posting-Host: 128.206.21.60
  9. X-Newsreader: Trumpet for Windows [Version 1.0 Rev B final beta #4]
  10.  
  11. I do not why the assignment operator can only be overloaded as a member 
  12. function in a class such as:
  13.  
  14.           class myclass {
  15.               int i;
  16.           public:
  17.               myclass operator= (myclass &A) {
  18.                  i = A.i;
  19.                  return *this;
  20.               }
  21.           };
  22.  
  23. Why does not the following frind overloading work?
  24.  
  25.               mycalss operator= (myclass &A, myclass &B) {
  26.                    A.i = B.i;
  27.                    return A;
  28.               }
  29.  
  30. thank you for your help
  31.  
  32.